Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exam Mode: Add sidebar to student view to display exams #8662

Closed
wants to merge 81 commits into from

Conversation

edkaya
Copy link
Contributor

@edkaya edkaya commented May 24, 2024

Checklist

General

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data.
  • I strictly followed the client coding and design guidelines.
  • Following the theming guidelines, I specified colors only in the theming variable files and checked that the changes look consistent in both the light and the dark theme.
  • I added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I added authorities to all new routes and checked the course groups for displaying navigation elements (links, buttons).
  • I documented the TypeScript code using JSDoc style.
  • I added multiple screenshots/screencasts of my UI changes.
  • I translated all newly inserted strings into English and German.

Motivation and Context

In the current design of Artemis, we display real and test exams side by side. In other parts of Artemis, such as lectures and exercises, we use sidebars to group elements. To maintain consistency, the sidebar is also implemented in the course exams view in order to group and display real and test exams. This implementation is therefore a part of the new design in exam mode.

Description

  • Added the new sidebar into course exams
  • Since the current implementation covers both exam-participation-cover (welcome&end page) and exam-participation components in the same route url, the problem occured in a way that both welcome page and exam itself is displayed in the sidebar content. But the intended behaviour is to display welcome-page in the sidebar content, whereas the exam itself as full-screen. To omit this problem, the approach is implemented where sidebars and breadcrum get hidden when an exam is started. Therefore, we can now see the exam in full-screen again.
  • Welcome-page, exam-summary and submission error text are displayed in sidebar-content.
  • Note: Status icons in the sidebar cards for the exams in the sidebar will be implemented in a follow-up PR (See screenshots)

Steps for Testing

Prerequisites:

  • 1 Admin
  • 1 Students
  • 1 Real Exam
  • 1 Test Exam

(There are already three exams available under my course "Ege Dogu Kaya" on TS4 and only one test account (artemis_test_user_4) is registered for these three exams, feel free to register other accounts if needed. If you want to use these three exams to test it, you can skip first 8 steps. )

  1. Log in to Artemis with Admin account
  2. Navigate to Course Management
  3. Select a Course
  4. Navigate to Exams
  5. Create an Exam
  6. Register the student account
  7. Go to Student Exams
  8. Click 'Generate individual exams' and then 'Prepare exercise start'
  9. Log in to Artemis with Student account
  10. Select the course
  11. Navigate to Exams
  12. Verify that you have real and test exams being displayed in the sidebar with correct information
  13. Verify that you can hide the sidebar with toggle feature (CTRL+Shift+B)
  14. Verify that you see the welcome page of the exam in the sidebar-content
  15. Verify that you are correctly navigated to exam after clicking on 'Start'
  16. Verify that you can see the exam summary in the sidebar-content when you finished the exam

Exam Mode Testing

Prerequisites:

  • 1 Student
  • 1 Exam
  1. Log in to Artemis
  2. Participate in the exam as a student
  3. Make sure that nothing changes in the exam itself, both functionally and visually.

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked






Review Progress

Performance Review

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Exam Mode Test

  • Test 1
  • Test 2

Test Coverage

Class/File Line Coverage Confirmation (assert/expect)
course-exams.component.ts 91.17%
course-overview.service.ts 92.3%

Screenshots

  • Current system
Screenshot 2024-05-26 at 02 07 04
  • Intended changes according to the mockups in Figma
Screenshot 2024-05-25 at 17 11 50
  • Implemented design
Screenshot 2024-05-25 at 20 00 09

Summary by CodeRabbit

  • New Features

    • Improved handling of exam and course components with conditional rendering and updated styling.
    • Added support for displaying exam-specific details like start time, working time, and attainable points in the sidebar.
  • Bug Fixes

    • Corrected trailing commas in various Angular template bindings to ensure proper functionality.
  • Refactor

    • Updated course overview and exam components with clearer, more user-friendly interfaces.
    • Enhanced logic for handling exam participation and assessment.
  • Tests

    • Added new tests to verify functionality for exam and sidebar components handling different scenarios.
  • Documentation

    • Updated translations in the German and English student dashboard JSON files for new exam-related terms.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Outside diff range comments (3)
src/test/javascript/spec/component/shared/sidebar/sidebar-card-large.component.spec.ts (1)

Line range hint 24-34: Avoid duplicating beforeEach setup hooks within the same describe block to ensure clarity and efficiency in test setup.

- beforeEach(() => {
-     router = new MockRouter();
-     TestBed.configureTestingModule({
-         imports: [ArtemisTestModule, MockModule(RouterModule)],
-         declarations: [SidebarCardLargeComponent, SidebarCardItemComponent, MockRouterLinkDirective],
-         providers: [{ provide: Router, useValue: router }],
-     }).compileComponents();
- });
src/test/javascript/spec/component/shared/sidebar/sidebar.component.spec.ts (1)

Line range hint 39-44: Duplicate beforeEach setup hooks are present, which can lead to confusion and redundancy in test configurations.

- beforeEach(() => {
-     TestBed.configureTestingModule({
-         imports: [ArtemisTestModule, MockModule(FormsModule), MockModule(ReactiveFormsModule), MockModule(RouterModule)],
-         declarations: [
-             SidebarComponent,
-             SidebarCardMediumComponent,
-             SidebarCardItemComponent,
-             SidebarCardDirective,
-             SearchFilterPipe,
-             SearchFilterComponent,
-             MockPipe(ArtemisTranslatePipe),
-             MockRouterLinkDirective,
-         ],
-     }).compileComponents();
- });
src/main/webapp/app/exercises/quiz/participate/quiz-participation.component.html (1)

[!TIP]
Codebase Verification

The QuizMode enum definitions in both files include the modes: SYNCHRONIZED, BATCHED, and INDIVIDUAL. However, the switch-case block in the provided HTML snippet only handles practice and preview modes. This discrepancy indicates that not all possible quiz modes are covered in the switch-case block.

  • SYNCHRONIZED
  • BATCHED
  • INDIVIDUAL

Ensure all quiz modes are handled in the switch-case block to prevent any unhandled cases.

Analysis chain

Line range hint 7-13: Ensure that all possible quiz modes are handled in the switch-case block to prevent any unhandled cases.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all quiz modes are handled in the switch-case block.

# Test: Search for all quiz mode definitions and ensure they are covered in the switch-case.
rg --type typescript 'enum QuizMode'

Length of output: 73



Script:

#!/bin/bash
# Description: Verify all quiz modes are handled in the switch-case block.

# Test: Search for all quiz mode definitions and ensure they are covered in the switch-case.
rg --type ts 'enum QuizMode'

Length of output: 174



Script:

#!/bin/bash
# Description: Extract QuizMode enum definitions from the identified files.

# Extracting QuizMode enum from src/test/playwright/support/constants.ts
rg --type ts 'export enum QuizMode' -A 5 src/test/playwright/support/constants.ts

# Extracting QuizMode enum from src/main/webapp/app/entities/quiz/quiz-exercise.model.ts
rg --type ts 'export enum QuizMode' -A 5 src/main/webapp/app/entities/quiz/quiz-exercise.model.ts

Length of output: 417

@edkaya edkaya force-pushed the feature/exam-mode/add-sidebar-with-large-cards branch 3 times, most recently from 49bddb3 to b5cce62 Compare June 20, 2024 19:42
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Outside diff range comments (5)
src/test/javascript/spec/component/shared/sidebar/sidebar-card-large.component.spec.ts (1)

Line range hint 24-34: Remove duplicate beforeEach block to adhere to best practices and avoid unnecessary test setup duplication.

- beforeEach(() => {
-     router = new MockRouter();
-     TestBed.configureTestingModule({
-         imports: [ArtemisTestModule, MockModule(RouterModule)],
-         declarations: [SidebarCardLargeComponent, SidebarCardItemComponent, MockRouterLinkDirective],
-         providers: [{ provide: Router, useValue: router }],
-     }).compileComponents();
- });
src/test/javascript/spec/component/shared/sidebar/sidebar.component.spec.ts (1)

Line range hint 39-44: The beforeEach block is duplicated, which could lead to maintenance issues and unexpected behavior in tests. Consider removing the duplicate to streamline the test setup.

- beforeEach(() => {
-     TestBed.configureTestingModule({
-         imports: [ArtemisTestModule, MockModule(FormsModule), MockModule(ReactiveFormsModule), MockModule(RouterModule)],
-         declarations: [
-             SidebarComponent,
-             SidebarCardMediumComponent,
-             SidebarCardItemComponent,
-             SidebarCardDirective,
-             SearchFilterPipe,
-             SearchFilterComponent,
-             MockPipe(ArtemisTranslatePipe),
-             MockRouterLinkDirective,
-         ],
-     }).compileComponents();
- });
src/main/webapp/app/overview/course-statistics/course-statistics.component.html (1)

[!TIP]
Codebase Verification

The search results indicate that @if and @for directives are used extensively in the codebase. However, these directives are not standard Angular directives, which suggests a potential issue.

  • Location to address:
    • Replace @if with *ngIf
    • Replace @for with *ngFor

Ensure that the correct Angular directives are used for conditional rendering and iteration.

Analysis chain

Line range hint 1-1: Review the usage of @if and @for directives.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Search for usages of `@if` and `@for` to ensure they are correctly used in place of *ngIf and *ngFor.

# Test: Search for the directives in Angular HTML templates. Expect: Only valid usages of `@if` and `@for`.
rg --type html '@if|@for' src/main/webapp/**/*.html

Length of output: 121



Script:

#!/bin/bash
# Description: Correct the file path issue and search for usages of `@if` and `@for` directives in Angular HTML templates.

# Locate all HTML files within src/main/webapp/app/overview/course-statistics/
fd --type f --extension html --exec rg '@if|@for' {}

Length of output: 269708

src/main/webapp/app/exercises/shared/dashboards/tutor/exercise-assessment-dashboard.component.html (2)

Line range hint 3-5: Ensure proper null checking for exercise when accessing properties like title to prevent runtime errors.

Consider using optional chaining (exercise?.title) to safely access properties.


Line range hint 33-33: The repeated conditional check for numberOfSubmissions.late > 0 could be optimized by storing the result in a temporary variable and using it in the template to reduce redundancy.

- @if (numberOfSubmissions.late > 0) {
+ let hasLateSubmissions = numberOfSubmissions.late > 0;
+ @if (hasLateSubmissions) {

@edkaya edkaya force-pushed the feature/exam-mode/add-sidebar-with-large-cards branch from 88f0784 to b5cce62 Compare June 20, 2024 19:57
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Outside diff range comments (1)
src/test/javascript/spec/component/shared/sidebar/sidebar-card-large.component.spec.ts (1)

Line range hint 24-34: Refactor to combine duplicate setup hooks.

There are two beforeEach blocks that can be combined to streamline the setup process and reduce redundancy.

- beforeEach(() => {
-    router = new MockRouter();
-    TestBed.configureTestingModule({
-        imports: [ArtemisTestModule, MockModule(RouterModule)],
-        declarations: [SidebarCardLargeComponent, SidebarCardItemComponent, MockRouterLinkDirective],
-        providers: [{ provide: Router, useValue: router }],
-    }).compileComponents();
-});
-
- beforeEach(() => {
-    fixture = TestBed.createComponent(SidebarCardLargeComponent);
-    component = fixture.componentInstance;
-    component.sidebarItem = {
-        title: 'testTitle',
-        id: 'testId',
-        size: 'L',
-    };
-    component.itemSelected = true;
-    fixture.detectChanges();
-});
+ beforeEach(() => {
+    router = new MockRouter();
+    TestBed.configureTestingModule({
+        imports: [ArtemisTestModule, MockModule(RouterModule)],
+        declarations: [SidebarCardLargeComponent, SidebarCardItemComponent, MockRouterLinkDirective],
+        providers: [{ provide: Router, useValue: router }],
+    }).compileComponents();
+
+    fixture = TestBed.createComponent(SidebarCardLargeComponent);
+    component = fixture.componentInstance;
+    component.sidebarItem = {
+        title: 'testTitle',
+        id: 'testId',
+        size: 'L',
+    };
+    component.itemSelected = true;
+    fixture.detectChanges();
+});

@edkaya edkaya removed ready to merge lock:artemis-test4 maintainer-approved The feature maintainer has approved the PR labels Jun 21, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range comments (1)
src/main/webapp/app/types/sidebar.ts (1)

Line range hint 56-56: Avoid Using any for Type Definitions:

The use of any for quickActionIcons should be avoided as it bypasses TypeScript's type checking. It's recommended to define a more specific type that accurately describes the expected properties.

- quickActionIcons?: any;
+ quickActionIcons?: QuickActionIcon[]; // Define this type based on the expected properties

@edkaya edkaya added ready to merge maintainer-approved The feature maintainer has approved the PR labels Jun 21, 2024
Copy link
Contributor

@DominikRemo DominikRemo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reapprove after merge conflict

Copy link
Contributor

@muradium muradium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reapprove after merge

@krusche krusche removed ready to merge maintainer-approved The feature maintainer has approved the PR labels Jun 21, 2024
@krusche krusche modified the milestones: 7.3.0, 7.3.1 Jun 22, 2024
@edkaya edkaya closed this Jun 24, 2024
@krusche krusche removed this from the 7.3.1 milestone Jun 24, 2024
@krusche krusche deleted the feature/exam-mode/add-sidebar-with-large-cards branch June 24, 2024 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) component:Exam Mode tests user interface
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

10 participants